﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,minimal-ui">
<link href="http://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<%@ include file="/WEB-INF/component/commonCSS.jsp"%>

<style type="text/css">
.inf{
   position:fixed;
   top:150px;
   right:15px;
   width:150px;
   height:250px;
   background-color:#3c8dbc;
   z-index:999;
   }
p.infTitle{
   width:120px;
   color:#fff;
   margin-left:10px;
   margin-top:8px;
   line-height:9px;
  }
  
p.infWord{
  width:120px;
  color:#e1ebf3;
  margin-left:10px;
  line-height:14px;
  margin-top:-4px;
}
.opacity50 { /* 75% opaque */
    opacity:0.75;
    -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=75)";
    filter:alpha(opacity=75);
    zoom:1
}
#shclNs {
           position:fixed;
           left:0px;
           top:0px;
           width:100%;
           height:100%;
           opacity:0.75;
           -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=75)";
           filter:alpha(opacity=75);
           background-color: gray;
           margin:0px;
           padding:0px;
           z-index:999999;
           background:url('${ctx}/lib/img/loading.gif') no-repeat center center;
        }
</style>

</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame" style="height:650px;overflow-y:scroll;"  >
<div id="shclNs" ></div>
<div class="box box-primary" id="more" style="width:110px;height:35px;background-color:#222c32;position:absolute;z-index:9999;left:850px;top:100px;display:none;font-size:12px;border-top-color:#222c32;">
            <div class="box-body home-message" id="moreOp" >
            </div>
</div>
	<section class="content-header">
		<h1>产品资质管理</h1>
		<ol class="breadcrumb">
			<li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
			<li class="active"><a href="#">基础库管理</a></li>
			<li class="active"><a href="#">企业产品库管理</a></li>
			<li class="active"><a href="#">资质管理</a></li>
		</ol>
		
</section>
<div class="opacity50 inf">
<p class="infTitle"><b>药品编码:</b></p>
<p class="infWord">${drugCode}</p>
<p class="infTitle"><b>通用名:</b></p>
<p class="infWord">${drugName}</p>
<p class="infTitle"><b>剂型:</b></p>
<p class="infWord">${form}</p>
<p class="infTitle"><b>规格:</b></p>
<p class="infWord">${unit}</p>
<p class="infTitle"><b>生产企业:</b></p>
<p class="infWord">${prodCompName}</p>
</div>
<section class="content" >
<div class=" box box-success"  >
<div id="wrapper">
<div id="content" ></div>
<script id="test" type="text/html">
  {{each rows as row i}}
			<div class="col-xs-6 col-lg-4 hei">
				<div class="wrapper2 ">
								<!-- <div class="dropdown">
								   <button type="button" class="btn dropdown-toggle" id="dropdownMenu1" 
								      data-toggle="dropdown">编辑<span class="caret"></span>
								   </button>
								   <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
								      <li role="presentation" >
								         <a role="menuitem" tabindex="-1" href="javascript:"></a>
								         <a role="menuitem" tabindex="-1" href="javascript:">修改</a>
								         <a role="menuitem" tabindex="-1" href="${ctx}/stdCompdrugprofile/toStdCompdrugprofileLogList.html?compprofileId={{row.compprofileId}}">维护记录</a>
								      </li>
								   </ul>                            
								</div> -->
					<a id=""  href="javascript:showImg('{{row.profilePicAddr}}','{{row.profileName}}');" ><img class="img-responsive" border="0" src="${ctx}/{{row.profilePicShortcutAddr}}"></a>
                    <div class="row" style=" margin-left: -12;margin-left: -23px;" >
						<div class="col-md-12">
							<p class="pull-left imgButton">
								<button type="button" class="btn btn-primary btn-sm" id="submitDicCompType" onclick="changeStatus('{{row.status}}','{{row.compprofileId}}');">{{row.status | formatStatusEdit}}</button>
							    <button type="button" class="btn btn-primary btn-sm" style="margin-left: 1px;" id="submitDicCompType" onclick="edit('{{row.compprofileId}}','{{row.profileCode}}','{{row.profileName}}','{{row.profileStarttimeStr}}','{{row.profileEndtimeStr}}','{{row.profilePicAddr}}','{{row.remarks}}');" style="margin-left:10px">修&nbsp;&nbsp;改</button>
								<a class="btn btn-primary btn-sm" href="${ctx}/stdCompdrugprofile/toStdCompdrugprofileLogList.html?compprofileId={{row.compprofileId}}">维护记录</a>
							</p>
						</div>
					</div>
                    <div class="row" style="margin-left:0px">
						<div class="col-md-12">
							<p class="pull-left">
								<div class="productInfo" >&nbsp;资质编号:<span class="productInfo" name="profileCode" >{{row.profileCode}}</span></div>
							</p>
						</div>
					</div>
					<div class="row"  style="margin-left:0px">
						<div class="col-md-12">
							<p class="pull-left">
								<div class="productInfo" >&nbsp;资质名称:<span class="productInfo" name="profileCode" >{{row.profileName}}</span></div>
							</p>
						</div>
					</div>
					<div class="row"  style="margin-left:0px">
						<div class="col-md-12">
							<p class="pull-left">
								<div class="productInfo" >&nbsp;资质有效期开始时间:<span class="productInfo" name="profileTime" >{{row.profileStarttimeStr}}</span></div>
						    </p>
						</div>
					</div>
					<div class="row"  style="margin-left:0px">
						<div class="col-md-12">
							<p class="pull-left">
								<div class="productInfo" >&nbsp;资质有效期截至时间:<span class="productInfo" name="profileTime" >{{row.profileEndtimeStr}}</span></div>
						    </p>
						</div>
					</div>
					<div class="row"  style="margin-left:0px">
						<div class="col-md-12">
							<p class="pull-left">
								<div class="productInfo" >&nbsp;状态:<span class="productInfo" name="status" >{{row.status | formatStatus}}</span></div>
							</p>
						</div>
					</div>
					<div class="row"  style="margin-left:0px">
						<div class="col-md-12">
							<p class="pull-left">
								<div class="productInfo" >&nbsp;备注:<span class="productInfo" name="remarks" >{{row.remarks}}</span></div>
							</p>
						</div>
					</div>
					
				</div>
			</div>
 {{/each}}
		</script>	
			
			
		</div>

	<!--<div class="main">
 		 <div class="contre">
			<label id="addNew" class="btn btn-default btn-sm">新&nbsp;&nbsp;增</label>
			<a href="javascript:history.go(-1)" class="btn btn-default btn-sm">返&nbsp;&nbsp;回</a>
   		 </div>
	</div>  -->




 <div class="row productall">
	      <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
			<div class="modal-dialog">
            	<div class="modal-content">
                	<div class="modal-header bg-primary">
                    	<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    	<h5 class="modal-title" id="exampleModalLabel">产品资质</h5>
                    </div>
                    <form  id="form" action="/medstgmini/stdCompdrugprofile/saveOrUpdateStdCompdrugprofile.html?compId=${compId}&prodId=${prodId}" method="post" enctype="multipart/form-data">
                    <div class="modal-body">
                    	<div class="form-group form-group-xs">
							<label for="recipient-name" class="control-label">产品资质名称：</label>
							<div class="" >
                            	<input type="text" class="form-control" id="profileName" name="profileName" placeholder="产品资质名称" maxlength="128">
                        	</div>
                    	</div>
                 <!--    	<div class="form-group form-group-xs">
							<label for="recipient-name" class="control-label">产品资质类型：</label>
                        	<input  id="delId"  type="hidden">
                            <input class="form-control" id="delName" placeholder="请选择产品资质类型" type="text" onclick='editSubComp();' ><span class="required" id="delNameFail"></span>	
                    	</div> -->
                       <div class="form-group form-group-xs">
							<label for="recipient-name" class="control-label">产品资质图片：</label>
	                                <input id="acctApprovalPicDir" name="licence" type="file" />
                    	</div>
                    	<div class="form-group form-group-xs">
	                    	<label>有效期起始日期：</label>
								<div class="input-group">
			           				  <input class="form-control" type="text" name="profileStarttimeStr" id="createTimeBegin"    placeholder="yyyy-MM-dd"
	                                  onFocus="var endDate=$dp.$('createTimeEnd');WdatePicker({maxDate:'#F{$dp.$D(\'createTimeEnd\')}'})" maxlength="25"/>
			       				</div>
	                    	</div>
                    	<div class="form-group form-group-xs">
	                    	<label>有效期截至日期：</label>
								<div class="input-group">
			           				 <input class="form-control" type="text" name="profileEndtimeStr" id="createTimeEnd"   placeholder="yyyy-MM-dd" maxlength="25"
	                       				onFocus="WdatePicker({minDate:'#F{$dp.$D(\'createTimeBegin\')}'})" />
			       				</div>
                    	</div>
                    	
						<div class="form-group form-group-xs">
	                        <label for="txtDrugForm">备注：</label>
	                       <textarea class="form-control"  placeholder="备    注" id="remark" name="remarks" maxlength="512" ></textarea>
                       </div>
                       <input type="text" id="compprofileId" name="compprofileId" style="display:none" />
						<div id="twoSpec" style="display:none"></div>
					</div>
					</form>
                    <div class="modal-footer">
                     <input hidden="true" id="spid"/>
           			   <input hidden="true" id="spfatherid"/>
                        <button type="button" class="btn btn-primary btn-sm" id="submitDicCompType" onclick="save();">保&nbsp;存</button>
                        <button type="button" class="btn btn-danger btn-sm" data-dismiss="modal" id="closeDicCompType">关&nbsp;闭</button>
                    </div>
                </div>
            </div>
        </div>
	</div>
</div>
<div style="height:50px"></div>
</section>
 
<div class="mainA">
<div class="mainB"></div>
<div class="mainC"></div>
<div class="main" >
 	<label id="addNew" class="btn btn-primary btn-sm">新&nbsp;增</label>
	<a href="javascript:history.go(-1)" class="btn btn-danger btn-sm">返&nbsp;回</a> 		 
</div>
</div>

</body>
</html>
<%@ include file="/WEB-INF/component/commonJS.jsp"%>
<script type="text/javascript">
/*格式化启用/停用 下拉编辑*/
template.helper('formatStatusEdit', function(data) {
	return data == 1 ? "停&nbsp;&nbsp;用" : "启&nbsp;&nbsp;用";
});	
/*格式化启用/停用 */
template.helper('formatStatus', function(data) {
	return data == 1 ? "已启用" : "已停用";
});
var records = 0;//总条目
var postData = {"rows":3,"page":1};//rows 一页展示多少条   page当前页数
	$(function() {

		//停用启用
		$('#showOperate').children().eq(0).bind("click", function() {
			alert("WO " + $('#showOperate').children().eq(0).html());
		})

		//	alert($(gg).html());
		//	$(gg).children().eq(1).bind("click",function(){
		//		alert("WO "+$('#showOperate').children().eq(1).html());
		//	})	
		
		getList(postData);
	    $(window).scroll(function() {
           // console.log( $(document).scrollTop());// 获取垂直滚动的距离
            if ($(document).scrollTop() >= $(document).height() - $(window).height()) {
            	postData.page++;
            	if (postData.page <=Math.ceil(records/postData.rows)) {
            		getList(postData);
            	} 
            }
         });
});
	function getList(postData){
		$("#shclNs").show();
			$.post('getStdCompdrugprofile.html?prodId=${prodId}&compId=${compId}',
					postData, function(result) {
						if (result.success) {
							$("#shclNs").hide();
							var html = template('test', result);
							$('#content').append(html);
							var content=$('#content').html();
							if(content==null||content.length==0){
								$('#content').css({
									  "color":"red",
								      "font-family":"Arial",
								      "font-size":"20px",
								      "padding":"5px"
								});
								$('#content').html("该产品暂无任何资质！");
							}
							records=result.records;  //总条数
						} else {
							$.HN.message.alert("数据获取失败", '信息', 'error');
						}
					}, "json");
		}
	
	$('#addNew').click(function() {
		$('#profileCode').val("");
		$('#profileName').val("");
		$('#createTimeBegin').val("");
		$('#createTimeEnd').val("");
		$('#remark').val("");
		$('#acctApprovalPicDir').val("");
		$('#exampleModalLabel').html("产品资质新增");
		$('#exampleModal').modal({
			keyboard : true
		});
	});
	function changeStatus(status,compprofileId) {
		var msg = status == 1 ? "停用" : "启用";//页面提示逻辑
		var statu = status == 1 ? 0:1;//后台数据逻辑
		$.HN.message.confirm("确定"+msg+"吗？", '', '').on(function(e) {
			if (e) {
				$.post('updateStdCompdrugprofileStatus.html', {
					"status" : statu,"compprofileId":compprofileId
				}, function(result) {
					if (result.success) {
						$('#content').empty();
						postData.page=1;
						console.log("停用/启用"+JSON.stringify(postData));
						getList(postData);
						$.HN.message.alert(result.msg, '信息', 'success');
					} else {
						$.HN.message.alert(result.msg, '信息', 'error');
					}
				}, "json");
			}
		});
	}
	
	function edit(compprofileId, profileCode,profileName,profileStarttime,profileEndtime,profilePicAddr,remarks) {
		$('#profileCode').val("");
		$('#profileName').val("");
		$('#createTimeBegin').val("");
		$('#createTimeEnd').val("");
		$('#remark').val("");
		$('#acctApprovalPicDir').val("");
		$('#compprofileId').val();
		$('#exampleModalLabel').html("产品资质编辑");
		$('#exampleModal').modal({
			keyboard : true
		});
		$('#profileCode').val(profileCode);
		$('#profileName').val(profileName);
		$('#createTimeBegin').val(profileStarttime);
		$('#createTimeEnd').val(profileEndtime);
		$('#remark').val(remarks);
		$('#compprofileId').val(compprofileId);
	}

	function validate() {
		var profileName = $.trim($("#profileName").val());
		if (profileName == null || profileName == "") {
			$.HN.message.alert("请输入产品资质名称！", "消息", "info");
			return false;
		}
		var createTimeBegin = $.trim($("#createTimeBegin").val());
		if (createTimeBegin == null || createTimeBegin == "") {
			$.HN.message.alert("请选择起始日期！", "消息", "info");
			return false;
		}

		var createTimeEnd = $.trim($("#createTimeEnd").val());
		if (createTimeEnd == null || createTimeEnd == "") {
			$.HN.message.alert("请选择截至日期！", "消息", "info");
			return false;
		}
		return true;
	}
	function save() {
		if (validate()) {
		$.HN.message.confirm('确定要保存吗？', '提示信息', '确定').on(
				function(e) {
					if (e) {
						$("#form").ajaxSubmit(
								{
									dataType : "json",
									timeout : 10000,
									success : function(result, statusText) {
										if (result.success) {
											$('#content').empty();
											postData.page=1;
											console.log("赋值"+JSON.stringify(postData));
											$('#exampleModal').modal('hide');
											getList(postData);
											$.HN.message.alert("操作成功！", "消息","success");
										} else {
											$.HN.message.alert(result.msg
													|| "提交失败！", "消息", "error");
										}
									}
								});

					}
				});
		}
	}
	function showImg(imgPath,profileName) {
		var url = "/medstgmini/acctInfo/toImg.html";
		$.HN.dialog.open({
			"id" : "showImg",
			"title" : profileName,
			"url" : url,
			"data" : {
				"imgPath" : imgPath
			},
			"width" : 800,
			"height" : 400,
			"closefunc" : function(params) {
				if (params) {

				}
			}
		});
	}
/* 	
    function editSubComp() {
    	$('#editSubComp').modal({
			keyboard : true
		});
	}
    function editSubComp(){
   	 $.HN.dialog.opendialog(1,"资质类型列表","/medstgmini/bidHospplan/toPSCompListJsp.html","800px","400px",operResult);
   }
    function operResult(val){
    	var strs = new Array();
        strs = val.split("|$");
        	if (val.length>0) {
				$("#delId").val(strs[0]);
				$("#delName").val(strs[1]);
			}
    	}

	 */
</script>